package emulator.unittest.hardware.nmos6502.timing;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

import emulator.EmulatorException;

public class ZeroPageXTest {

	TimingTestBase test_base = null;
	
	@Before
	public void setUp() throws Exception {
		test_base = new TimingTestBase();
	}
	
	@Test
	public void testADC() throws EmulatorException
	{
		assertEquals(4, getCycles(0x75));
	}
	
	@Test
	public void testAND() throws EmulatorException
	{
		assertEquals(4, getCycles(0x35));
	}
	
	@Test
	public void testASL() throws EmulatorException
	{
		assertEquals(6, getCycles(0x16));
	}
	
	@Test
	public void testCMP() throws EmulatorException
	{
		assertEquals(4, getCycles(0xD5));
	}
	
	@Test
	public void testDEC() throws EmulatorException
	{
		assertEquals(6, getCycles(0xD6));
	}
	
	@Test
	public void testEOR() throws EmulatorException
	{
		assertEquals(4, getCycles(0x55));
	}
	
	@Test
	public void testINC() throws EmulatorException
	{
		assertEquals(6, getCycles(0xF6));
	}
	
	@Test
	public void testLDA() throws EmulatorException
	{
		assertEquals(4, getCycles(0xB5));
	}
	
	@Test
	public void testLDY() throws EmulatorException
	{
		assertEquals(4, getCycles(0xB4));
	}
	
	@Test
	public void testLSR() throws EmulatorException
	{
		assertEquals(6, getCycles(0x56));
	}
	
	@Test
	public void testORA() throws EmulatorException
	{
		assertEquals(4, getCycles(0x15));
	}
	
	@Test
	public void testROL() throws EmulatorException
	{
		assertEquals(6, getCycles(0x36));
	}
	
	@Test
	public void testROR() throws EmulatorException
	{
		assertEquals(6, getCycles(0x76));
	}
	
	@Test
	public void testSBC() throws EmulatorException
	{
		assertEquals(4, getCycles(0xF5));
	}
	
	@Test
	public void testSTA() throws EmulatorException
	{
		assertEquals(4, getCycles(0x95));
	}
	
	@Test
	public void testSTY() throws EmulatorException
	{
		assertEquals(4, getCycles(0x94));
	}
	
	private int getCycles(int opcode) throws EmulatorException
	{
		test_base.setCommand(0, opcode, 0x44, 0);
		test_base.execute();
		return test_base.getElapsedCycles();
	}
}
